/*
 * Copyright 2011 The Rusted Roof, LLC.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package org.proteusframework.platformservice.persistence.api;

import java.util.Iterator;
import java.util.List;

/**
 * Wraps a result set derived from either {@link IMessageBeanManager#executeQuery(Class, String)}  or
 * {@link IMessageBeanManager#executeQuery(Class, String, Object...)}.
 *
 * @author Tacoma Four
 */
public interface IResultSet<T>
{
    /**
     * Number of records in the result set.
     *
     * @return Record count
     */
    int count();

    /**
     * Underlying list that represents the result set.
     *
     * @return Result set list
     */
    List<T> list();

    /**
     * Creates an iterator against the backing list.
     *
     * @return Iterator that walks the result set.
     */
    Iterator<T> iterator();

    /**
     * In situations where the query is expected to return zero or one row, returns either the first record
     * found or null if no records matched the given query.
     *
     * @return First record from the backing list, or null if the size of the list was 0
     */
    T getUniqueResult();
}
